<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script>

    var agentInfo = navigator.userAgent.toLowerCase();
    console.log(typeof agentInfo);
    console.log(agentInfo);
    if (agentInfo.indexOf('android')!=-1 || agentInfo.indexOf('iphone')!=-1){
        location.href = '6-2phone.html'
    }


    /*
    if (agentInfo.indexOf('android')!=-1){
        alert('当前访问的是android手机')
    } else if (agentInfo.indexOf('iphone')!=-1){
        alert('当前访问的是iphone手机')
    }*/

    //查找字符串中有没有 android 或 iphone字样



    var agentInfo = navigator.userAgent.toLowerCase();
    console.log(agentInfo);

    var r = new RegExp("iphone");
    console.log(r.test(agentInfo));
    if (r.test(agentInfo))alert('您当前使用的是iPhone手机');

</script>
<h2>我是网页版的页面</h2>
</body>
</html>